package com.tjetc.utils;

public class DateJudge {
    public static boolean dateJudge (String str){
        int year=Integer.parseInt(str.substring(0,4));
        int month=Integer.parseInt(str.substring(4,6));
        int day=Integer.parseInt(str.substring(6,8));
        int hour=Integer.parseInt(str.substring(8,10));
        int minute=Integer.parseInt(str.substring(10,12));
        int second=Integer.parseInt(str.substring(12,14));
        int dayRange=28;
        //设置日期范围
        if (year%4==0&&year%100!=0||year%400==0){
            dayRange=29;
        }
        //判断月份和设置日期时间范围
        if (month>0&&month<13){
            if (month==1||month==3||month==5||month==7||month==8||month==10||month==12){
                dayRange=31;
            }else if (month==4||month==6||month==9||month==11){
                dayRange=30;
            }
        }else {
            return false;
        }
        //判断日期
        if (day<0||day>dayRange){
            return false;
        }
        //判断时间
        if (hour<0||hour>24){
            return false;
        }
        //判断分钟
        if (minute<0||minute>60){
            return false;
        }
        //判断秒
        if (second<0||second>60){
            return false;
        }
        return true;

    }
}
